import Login from "../pages/admins/login.js";
import Reg from "../pages/admins/reg.js";
import usersLogin from "../pages/users/usersLogin.js";
import usersReg from "../pages/users/usersReg.js";
import Info from "../pages/info.js";
import movies from "./movies.js";
import theaters from "./theaters.js";
import order from "./order.js";
import schedules from "./schedules.js";

import cinemas from "./cinemas.js";
import seats from "./seats.js";
import adnubs from "./admins.js";
import userslist from "./userslist";
//定义路由
var routes = {
  "/login": () => {
    new Login({ el: "#app" });
  },
  "/reg": () => {
    new Reg({ el: "#app" });
  },
  "/usersLogin": () => {
    new usersLogin({ el: "#app" });
  },
  "/usersReg": () => {
    new usersReg({ el: "#app" });
  },
  "/info": {
    on() {
      // 如果.info-content存在就不重复渲染
      if ($(".layui-body").length === 1) return;
      new Info({ el: "#app" });
    },
    ...movies,
    ...theaters,
    ...cinemas,
    ...adnubs,
    ...userslist,
    ...order,
    ...schedules,
    ...seats,
  },
};
// 初始化路由
var router = Router(routes).configure({ recurse: "forward" });

export const init = () => {
  router.init();
  location.hash = location.hash || "#/login";
};
// module.exports = router;
